package com.example.hp.qingyi.scenic.fragment.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.hp.qingyi.R;
import com.example.hp.qingyi.scenic.fragment.bean.StrategyBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by asus on 2018/11/12.
 */

public class StrategyAdapter extends RecyclerView.Adapter<StrategyAdapter.MyViewHolder>{
    private Context context;
    private List<StrategyBean.DataBean.ListBean> bean;

    public StrategyAdapter(Context context, List<StrategyBean.DataBean.ListBean> bean) {
        this.context = context;
        this.bean = bean;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.strategy_adapter_item, null);
        MyViewHolder myViewHolder=new MyViewHolder(inflate);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Picasso.with(context).load(bean.get(position).getPostcover()).into(holder.imageView);
        Picasso.with(context).load(bean.get(position).getUsermini()).into(holder.imageView2);
        holder.textView.setText(bean.get(position).getTitle());

    }

    @Override
    public int getItemCount() {
        return bean.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView,imageView2;
        TextView textView;
        public MyViewHolder(View itemView) {
            super(itemView);
            imageView=itemView.findViewById(R.id.strategy_item_img);
            imageView2=itemView.findViewById(R.id.strategy_item_img2);
            textView=itemView.findViewById(R.id.strategy_item_tv);
        }
    }
}
